/*
 * File Name：TrackEaser.java
 * Copyright：Copyright 2008-2012 CiWong.Inc. All Rights Reserved.
 * Description： TrackEaser.java
 * Modify By：PLA-ZJLIU
 * Modify Date：2012-12-14
 * Modify Type：Add
 */
package com.ciwong.ciwongwrite.mode;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;


/**
 *
 * @author PLA-ZJLIU
 * @version ciwong v.1.0 2012-12-14
 * @since ciwong v.1.0
 */
public class TrackEaser extends TrackMouse
{

    public static Paint eraserPaint;

    private static float eX;

    private static float eY;

    public TrackEaser()
    {
        super();
        if (eraserPaint == null)
        {
            eraserPaint = new Paint();
            eraserPaint.setAntiAlias(true);
            eraserPaint.setColor(Color.BLACK);
            eraserPaint.setStyle(Paint.Style.STROKE);
            eraserPaint.setStrokeWidth(2);
            eraserPaint.setFilterBitmap(true);
        }
    }

    @Override
    public void move(float x, float y)
    {
        super.move(x, y);
        eX = x;
        eY = y;
    }

    public void easer()
    {
        mPaint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    }


    @Override
    public void draw(Canvas mCanvas)
    {
        super.draw(mCanvas);
        if (isRecord)
        {
            mCanvas.drawCircle(eX, eY, width / 2, eraserPaint);
        }
    }

    public void draw(Canvas mCanvas, Canvas eCanvas)
    {
        super.draw(mCanvas);
        eCanvas.drawCircle(eX, eY, width / 2, eraserPaint);
    }

    @Override
    public String format(boolean touchDown)
    {
        panStyle = MouseMode.PAN_EASER;
        return super.format(touchDown);
    }
}
